package com.feilong.cn.mybatis.autoV2.Test;


import com.feilong.cn.mybatis.autoV2.config.AutoConfiguration;
import com.feilong.cn.mybatis.autoV2.mappers.IUserMapper;
import com.feilong.cn.mybatis.autoV2.mappers.UserBean;
import com.feilong.cn.mybatis.autoV2.plugin.AutoSelfPluginDemo;
import com.feilong.cn.mybatis.autoV2.session.AutoSqlSession;

/**
 * Created by yangxulong on 2018/4/2.
 */
public class TestDemo {
    public static void main(String[] args) throws ClassNotFoundException {

        AutoConfiguration configuration = new AutoConfiguration();
        configuration.addInterceptor(new AutoSelfPluginDemo());
        configuration.addScanClass(IUserMapper.class.getName());

        AutoSqlSession session = new AutoSqlSession(configuration);

        //直接使用Session.selectOne方法测试
        UserBean beanByName = session.SelectOne("com.feilong.cn.mybatis.autoV2.mappers.IUserMapper.selectByName", "name1");
        System.out.println(beanByName.getName());

//        调用Mapper测试
        IUserMapper mapper = session.GetMapper(IUserMapper.class);
        UserBean bean = mapper.selectByPrimaryKey(1);
        System.out.println(bean.getName());
    }
}
